package E2017;

import java.util.Arrays;
class student{
    // 声明变量
    private String sno;
    private String name;
    private String sex;
    private int age;
    private int java;
    // 含参构造方法
    public student(String sno, String name, String sex, int age, int java) {
        this.sno = sno;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.java = java;
    }
    // 设置访问私有成员方法
    public String getSno() {
        return sno;
    }
    public void setSno(String sno) {
        this.sno = sno;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public int getJava() {
        return java;
    }
    public void setJava(int java) {
        this.java = java;
    }
    // 遍历展示学员
    public static void show(student[] stu){
        System.out.println("----------学员信息------------");
        for (int i=0;i<stu.length;i++){
            System.out.println(stu[i].getSno()+"\t"+stu[i].getName()+"\t"+stu[i].getSex()+"\t"+stu[i].getAge()+"\t"+stu[i].getJava());
        }
    }
}
public class Exam1_1 {
    public static void main(String[] args) {
        // 创建学生对象数组存储学生对象
        student[] stu = new student[5];
        stu[0] = new student("01","tom","men",20,98);
        stu[1] = new student("02","tim","men",21,95);
        stu[2] = new student("03","jry","wom",23,88);
        stu[3] = new student("04","jar","men",22,90);
        stu[4] = new student("05","bat","wom",21,92);
        student.show(stu);
        // 定义数组存储java成绩信息
        int[] a = new int[5];
        int sum = 0;  // 求和
        int avg = 0;  // 求平均值
        for (int i=0;i<stu.length;i++){
            a[i] = stu[i].getJava();
            sum = sum + a[i];
        }
        Arrays.sort(a);
        avg = sum/a.length;
        System.out.println("最小值："+a[0]);
        System.out.println("最大值："+a[4]);
        System.out.println("平均值："+avg);
    }
}
